package com.example.demo.controller;

import com.example.demo.config.MyWebSocketHandler;
import com.example.demo.controller.data.ReturnData;
import com.example.demo.entity.MessageNum;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class UserController {
    //    @Resource
    @Resource
    private MyWebSocketHandler myWebSocketHandler;

    /**
     * 叫号
     */
    @PostMapping("callNumber")
    public ReturnData callNumber(@RequestBody MessageNum cinemaId) {
        System.out.println("有新的叫号请求:" + cinemaId.toString());
        myWebSocketHandler.sendMessageToAllClients(cinemaId);

        return ReturnData.ok(true);
    }

}
